//******************************************************************************
//this code is protected by the GNU affero GPLv3
//author:Sylvain BERTRAND <sylvain.bertrand AT gmail dot com>
//                        <digital.ragnarok AT gmail dot com>
//******************************************************************************
#include "globals.h"
s8 shell_get_shell_surface(struct client *c,u32 shell_surface_id,u32 surface_id)
{
  s8 r=LWL_OK;
  s32 surface_slot=0;
  while(1){
    if(surface_slot==CLIENT_OBJS_MAX){
      PERR("client(%d):shell::get_shell_surface surface_id=%u not found\n",
                                                              c->so,surface_id);
      r=LWL_ERR;goto exit;
    }
    if(!(c->objs[surface_slot].state&CLIENT_OBJ_INVALID)
       &&c->objs[surface_slot].state&CLIENT_OBJ_SURFACE
       &&c->objs[surface_slot].id==surface_id)
      break;
    ++surface_slot;
  }

  r=shell_surface_new_visible(c,shell_surface_id,surface_slot);
  if(r==LWL_ERR)
    PERR("client(%d):shell::get_shell_surface no room for new shell surface\n",
                                                                         c->so);
exit:
  return r;
}
